/**
 * @ClassName KP30_MaximumDepthOfBinaryTree
 * @Description: TODO
 * @Author: JCC
 * @CreateTime: 2023/10/26 12:56
 */

/**
 * 二叉树的最大深度
 */
public class KP30_MaximumDepthOfBinaryTree {
    //测试链接：https://leetcode.com/problems/maximum-depth-of-binary-tree/
    public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int val) {
            this.val = val;
        }
    }

    public int maxDepth(TreeNode root) {
        if (root == null) {
            return 0;
        }
        int leftSize = maxDepth(root.left) + 1;
        int rightSize = maxDepth(root.right) + 1;
        return Math.max(leftSize,rightSize);
    }

}
